package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Restaurant;
import com.ruoyi.system.service.IRestaurantService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 餐饮Controller
 *
 * @author 强盛酒店
 * @date 2023-03-08
 */
@RestController
@RequestMapping("/system/restaurant")
public class RestaurantController extends BaseController {
    @Autowired
    private IRestaurantService restaurantService;

    /**
     * 查询餐饮列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Restaurant restaurant) {
        startPage();
        List<Restaurant> list = restaurantService.selectRestaurantList(restaurant);
        return getDataTable(list);
    }

    /**
     * 获取餐饮详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(restaurantService.selectRestaurantById(id));
    }

    /**
     * 新增餐饮
     */
    @PostMapping
    public AjaxResult add(@RequestBody Restaurant restaurant) {
        return toAjax(restaurantService.insertRestaurant(restaurant));
    }

    /**
     * 修改餐饮
     */
    @PutMapping
    public AjaxResult edit(@RequestBody Restaurant restaurant) {
        return toAjax(restaurantService.updateRestaurant(restaurant));
    }

    /**
     * 删除餐饮
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(restaurantService.deleteRestaurantByIds2(ids));
    }
}
